classdef TestDotsThePlayablesManager < dotsTestCase
    
    properties
        pm;
    end
    
    methods
        function self = TestDotsThePlayablesManager(name)
            self = self@dotsTestCase(name);
        end
        
        function setUp(self)
            self.setUp@dotsTestCase;
            dotsThePlayablesManager.reset;
            self.pm = dotsThePlayablesManager.theObject;
        end
        
        function tearDown(self)
            dotsThePlayablesManager.reset;
            self.tearDown@dotsTestCase;
        end
        
        function testNew(self)
            className = 'dotsPlayableTone';
            object = self.pm.newObject(className);
            assertEqual(class(object), className, ...
                sprintf('should have new %s instance', className));
        end
        
        function testPlayTime(self)
            className = 'dotsPlayableTone';
            object = self.pm.newObject(className);
            object.isAudible = false;
            
            preplay = feval(self.pm.clockFunction);
            self.pm.mayPlayPlayable(object);
            postPlay = object.lastPlayTime;
            
            assertTrue(preplay < postPlay, ...
                'should have recorded new play time')
        end
    end
end